package com.lk.dto;

import lombok.Data;

/**
 * @author kun.li
 */
@Data
public class ResponseResult<T> {

    private int code;
    private String message;

    private T data;

    public static <T> ResponseResult<T> failed(String message) {
        return new ResponseResult<>(1, message, null);
    }
    public static <T> ResponseResult<T> failed() {
        return new ResponseResult<>(1, "请求失败", null);
    }
    public static <T> ResponseResult<T> ok(String message,T data) {
        return new ResponseResult<>(0, message, data);
    }
    public static <T> ResponseResult<T> ok() {
        return new ResponseResult<>(0, "请求成功", null);
    }

    public static <T> ResponseResult<T> ok(T data) {
        return new ResponseResult<>(0, "请求成功", data);
    }

    private ResponseResult(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
}
